import 'package:love_app/common/su_dio.dart';
import 'package:love_app/config/path_url.dart';
import 'package:love_app/model/response_model.dart';
import 'package:love_app/model/setting_user_header_model.dart';
import 'package:love_app/service/base_api.dart';

// 设置用户信息
class SeetingInfoApi extends BaseApi{

  // 设置用户昵称
  Future<bool> settingUserName(String token, String newName)async{
    String path = PathUrl.settingUserName;
    Map postData = {
      "nickname": newName,
    };
    ResponseModel responseModel = await SuDio().postRequest(path, headersMap: headerToken(token), data: postData);
    return isSuccess(responseModel.data);
  }

  // 设置用户头像
  Future<SettingUserHeaderModel> settingUserHeader(String token, String qiniuToken)async{
    String path = PathUrl.settingUserHeader;
    Map postData = {
      "attachment": qiniuToken,
    };
    ResponseModel responseModel = await SuDio().postRequest(path, headersMap: headerToken(token), data: postData);
    return SettingUserHeaderModel.fromJson(responseModel.toJsonModel);
  }
}